package XynLeen.GraduationProject.Fragments.Bills;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import XynLeen.GraduationProject.R;

public class Fragment_In extends Fragment implements View.OnClickListener,CompoundButton.OnCheckedChangeListener {

    private RadioGroup gp4;
    private RadioGroup gp5;
    private RadioButton bt_invest;
    private RadioButton bt_red;
    private RadioButton bt_salary;
    private RadioButton bt_savings;
    private RadioButton bt_support;
    private RadioButton bt_others;

    public static String curName;
    public static int curImgId;

    @Override
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        View view= inflater.inflate(R.layout.fragment_in, container, false);

        gp4=view.findViewById(R.id.group_4);
        gp5=view.findViewById(R.id.group_5);
        bt_invest=view.findViewById(R.id.in_invest);
        bt_red=view.findViewById(R.id.in_red);
        bt_salary=view.findViewById(R.id.in_salary);
        bt_savings=view.findViewById(R.id.in_savings);
        bt_support=view.findViewById(R.id.in_support);
        bt_others=view.findViewById(R.id.in_others);

        bt_invest.setOnCheckedChangeListener(this);
        bt_red.setOnCheckedChangeListener(this);
        bt_salary.setOnCheckedChangeListener(this);
        bt_savings.setOnCheckedChangeListener(this);
        bt_support.setOnCheckedChangeListener(this);
        bt_others.setOnCheckedChangeListener(this);

        return view;
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()){
            case R.id.in_invest:
                curName="投资";
                curImgId=R.mipmap.ic_in_investment;
                gp5.clearCheck();
                break;
            case R.id.in_red:
                curName="份子钱";
                curImgId=R.mipmap.ic_in_redenvelopes;
                gp5.clearCheck();
                break;
            case R.id.in_salary:
                curName="工资";
                curImgId=R.mipmap.ic_in_salary;
                gp5.clearCheck();
                break;
            case R.id.in_savings:
                curName="储蓄";
                curImgId=R.mipmap.ic_in_savings;
                gp4.clearCheck();
                break;
            case R.id.in_support:
                curName="父母援助";
                curImgId=R.mipmap.ic_in_support;
                gp4.clearCheck();
                break;
            case R.id.in_others:
                curName="其它";
                curImgId=R.mipmap.ic_in_others;
                gp4.clearCheck();
                break;
            default:
                break;
        }
    }
}
